<!-- 申诉记录 详情 -->
<template>
  <div class="appealDetails-box">
    <div class="mx-20 mt-20 mb-10 text-15 font-bold">申诉信息</div>
    <el-form ref="ruleForm" label-width="130px" class="mx-30">
      <div v-if="sourceNum === '1' || sourceNum === '2'">
        <el-form-item label="预算科目名称:">{{ dataInfo.subjectName }}</el-form-item>
        <el-form-item label="预算科目编码:">{{ dataInfo.subjectCode }}</el-form-item>
        <el-form-item label="日期:">{{ dataInfo.dtime }}</el-form-item>
        <el-form-item label="部门编码:">{{ dataInfo.deptCode }}</el-form-item>
        <el-form-item label="部门名称:">{{ dataInfo.deptName }}</el-form-item>
        <el-form-item label="摘要:">{{ dataInfo.description }}</el-form-item>
        <el-form-item label="金额(元):">{{ formatMoney(dataInfo.amount) }}</el-form-item>
        <el-form-item label="院区:">{{ dataInfo.yard | yardName }}</el-form-item>
      </div>

      <div v-if="sourceNum === '3'">
        <el-form-item label="预算科目名称:">{{ dataInfo.subjectName }}</el-form-item>
        <el-form-item label="预算科目编码:">{{ dataInfo.subjectCode }}</el-form-item>
        <el-form-item label="固定资产编码:">{{ dataInfo.assetNum }}</el-form-item>
        <el-form-item label="固定资产名称:">{{ dataInfo.assetName }}</el-form-item>
        <el-form-item label="部门编码:">{{ dataInfo.deptCode }}</el-form-item>
        <el-form-item label="部门名称:">{{ dataInfo.deptName }}</el-form-item>
        <el-form-item label="原值:">{{ formatMoney(dataInfo.originalValue) }}</el-form-item>
        <el-form-item label="开始使用日期:">{{ dataInfo.useStartDate }}</el-form-item>
        <el-form-item label="存放地点:">{{ dataInfo.site }}</el-form-item>
        <el-form-item label="使用人:">{{ dataInfo.operator }}</el-form-item>
        <el-form-item label="院区:">{{ dataInfo.yard | yardName }}</el-form-item>
      </div>

      <div v-if="sourceNum === '4'">
        <el-form-item label="预算科目名称:">{{ dataInfo.subjectName }}</el-form-item>
        <el-form-item label="预算科目编码:">{{ dataInfo.subjectCode }}</el-form-item>
        <el-form-item label="部门编码:">{{ dataInfo.deptCode }}</el-form-item>
        <el-form-item label="部门名称:">{{ dataInfo.deptName }}</el-form-item>
        <el-form-item label="预算:">{{ formatMoney(dataInfo.budgetRate) }}</el-form-item>
        <el-form-item label="执行:">
          <TableNew
            :data="[dataInfo]"
            :columns="table"
            :hide-pagination="true"
          />
        </el-form-item>
        <el-form-item label="执行率/偏差率(%):">{{ formatMoney(dataInfo.bias) }}</el-form-item>
      </div>

      <div v-if="type === 'edit'">
        <el-form-item label="上传附件:" class="dialog-up-file">
          <el-upload
            class="inline-block mb-10"
            action=""
            :auto-upload="false"
            :on-change="fileChange"
            :on-remove="remove"
            multiple
            :file-list="fileList"
          >
            <el-button icon="el-icon-upload2" size="mini" :loading="importLoading">点击上传</el-button>
          </el-upload>
        </el-form-item>

        <el-form-item label="备注:" prop="desc">
          <!--eslint-disable-next-line vue/no-mutating-props-->
          <el-input v-model="selectInfo.memo" type="textarea" placeholder="请输入备注" />
        </el-form-item>
      </div>

      <div v-else>
        <el-form-item label="附件:" class="dialog-up-file">
          <div v-for="(item, index) in fileList" :key="'fileList' + index">
            <a
              class="hover:text-blue-500"
              :href="item.url"
              target="_blank"
            >{{ item.name }}</a>
          </div>
        </el-form-item>

        <el-form-item label="备注:" class="dialog-up-file">
          <div>{{ selectInfo.memo }}</div>
        </el-form-item>
      </div>
    </el-form>

    <div v-if="type === 'check'">
      <div class="mx-20 mt-30 mb-10 text-15 font-bold">处理结果</div>
      <el-form ref="ruleForm" label-width="110px" class="ml-30">
        <el-form-item label="处理结果:">{{ resultInfo.result }}</el-form-item>
        <el-form-item label="处理意见:">{{ resultInfo.advice }}</el-form-item>
        <el-form-item label="处理人:">{{ resultInfo.handler }}</el-form-item>
        <el-form-item label="处理时间:">{{ resultInfo.handleTime }}</el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import upFileMixins from '@/mixins/budgetQuert/upFileMixins'

export default {
  name: 'AppealDetails',
  filters: {
    yardName(val) {
      let name = ''

      switch (val) {
        case 1:
          name = '三香'
          break
        case 2:
          name = '浒关'
          break
      }

      return name
    }
  },
  mixins: [upFileMixins],
  props: {
    selectInfo: {
      type: Object,
      default() {
        return {}
      }
    },

    type: {
      type: String,
      default: 'check'
    }
  },
  data() {
    return {
      sourceNum: '',
      dataInfo: {},
      resultInfo: '',
      table: [
        {
          title: '三香(%)',
          dataIndex: 'sxImplementationRate',
          format: true,
          align: 'right'
        },
        {
          title: '浒关(%)',
          dataIndex: 'xgImplementationRate',
          format: true,
          align: 'right'
        },
        {
          title: '合计(%)',
          dataIndex: 'total',
          format: true,
          align: 'right'
        }
      ]
    }
  },
  mounted() {
    this.sourceNum = this.selectInfo.sourceNum

    switch (this.sourceNum) {
      case '1':
      case '2':
        this.dataInfo = this.selectInfo.accountDetailVo || {}
        break
      case '3':
        this.dataInfo = this.selectInfo.detailVO || {}
        break
      case '4':
        this.dataInfo = this.selectInfo.entry || {}
        break
    }

    this.fileList = this.selectInfo.files || []
    this.resultInfo = {
      result: this.selectInfo.result,
      advice: this.selectInfo.advice,
      handler: this.selectInfo.handler,
      handleTime: this.selectInfo.handleTime
    }
  },
  methods: {
    formatMoney(data) {
      if (!data && data !== 0) return data
      const temp = parseFloat(data)
      return temp.toFixed(2)
    }
  }
}
</script>

<style lang="less">
.appealDetails-box {
  .el-form-item {
    margin-bottom: 0;
  }
}
</style>
